package com.hgxd.utils;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.PrimitiveIterator;

/**
 * @author wtf
 * @create 2023-11-15 18:29
 * @description :
 */
public class DateUtil {



    /**
     * 时间转化为字符串
     * @param time
     * @return yyyy-MM-dd HH:mm:ss
     */
    public static String timeToString(LocalDateTime time){
        //时间格式设置
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
         return time.format(dateTimeFormatter);
    }

    public static LocalDateTime stringToTime(String time){
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        return LocalDateTime.parse(time,dateTimeFormatter);
    }

}
